#ifndef MULTI_ENCODER_H_
#define MULTI_ENCODER_H_

#include "ChannelEncoder.h"
#include <string>
#include <unordered_map>
#include <mutex>
#include <utility>

class EncoderConsole
{
public:
    EncoderConsole(int que_size = 1) : que_size_(que_size) {};
    ~EncoderConsole()
    {
        std::lock_guard<std::mutex> lock(enc_map_mtx_);
        for (auto &it : enc_map_)
        {
            it.second->stop();
        }
    };

    int get_channel_num();
    void addChannel(std::string url, int dev_id = 0);
    int read(int channel_idx, std::shared_ptr<bm_image> &out_image);
    void push_img(int channel_idx, std::shared_ptr<bm_image> img_ptr);

private:
    std::unordered_map<int, std::shared_ptr<ChannelEncoder>> enc_map_;
    std::mutex enc_map_mtx_;
    int que_size_;
};

#endif